<?php
/**
 * @orm tablename articles
 */
class Article extends DomArObject {
	
	/**
	 * @orm plugin DomArDateTime(now)
	 */
	public $datetime;
	/**
	 * @orm plugin DomArDateTime(now)
	 */
	public $publishDateTime;
	/**
	 * @orm text
	 */
	public $headline;
	/**
	 * @orm text
	 */
	public $author;
	/**
	 * @orm longtext
	 */
	public $introduction;
	/**
	 * @orm longtext
	 */
	public $contents;
	/**
	 * @orm plugin DomArImage({autoRename=1r})
	 * @orm listener afterAdd afterAddImage
	 */
	public $image;
	/**
	 * @orm plugin DomArImage({autoRename=1r})
	 */
	public $icon;
	/**
	 * @orm text
	 */
	public $imageDescription;
	/**
	 * @orm text
	 */
	public $imageAuthor;
	
	/**
	 * @orm int(11)
	 */
	public $category;
	/**
	 * @orm has parents ArticleList inverse articles
	 */
	public $lists;
	
	/**
	 * @orm owns many ArticleComment inverse article
	 */
	public $comments;
	/**
	 * @orm bool
	 */
	public $allowComments = true;
	/**
	 * @orm owns many ArticleImage inverse article
	 */
	public $images;
	
	/**
	 * @orm owns child ArticlePoll inverse article
	 */
	public $poll;
	

	
	
	public function afterAddImage() {
		if( !$this->image->exists() ) return;	
		$this->image->resize(800,600);
		$this->icon = $this->image->copy();
		$this->icon->resize(100,100,false);
		$this->icon->cut(100,100);
	}
	
	public static function getCategories() {
		return array(
			1 => array(
				'name' => 'Kategooria 1',
			),
			2 => array(
				'name' => 'Kategooria 2',
			),
		);
	}
	
}
?>